using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Runtime.Remoting.Messaging;
using System.Text;
using System.Windows.Forms;
using Kupper;
using Kupper.Settings;
using ff14bot;
using ff14bot.Behavior;
using ff14bot.Enums;
using ff14bot.Helpers;
using ff14bot.Managers;
using ff14bot.Navigation;
using ff14bot.Objects;
using TreeSharp;
using Action = TreeSharp.Action;
using System.ComponentModel;
using System.Globalization;
using System.Configuration;

namespace Kupper.Settings
{
    internal class NinjaSettings : KupperSettings
    {

        public class CsvConverter : TypeConverter
        {
            // Overrides the ConvertTo method of TypeConverter.
            public override object ConvertTo(ITypeDescriptorContext context,
               CultureInfo culture, object value, Type destinationType)
            {
                List<String> v = value as List<String>;
                if (destinationType == typeof(string))
                {
                    return String.Join(",", v.ToArray());
                }
                return base.ConvertTo(context, culture, value, destinationType);
            }
        }
		
        public NinjaSettings(string filename = "Ninja-KupperSettings"): base(filename)
        {
        }
		
		[Setting]
		public static string MudraState { get; set; }

		[Setting]
		public static string lastspellused { get; set; }
		
		//AOE
		[Setting]
		[Category("AOE")]
        [DefaultValue(5)]
		[Description("If more than this number of targets are in range of Death Blossom, use AOEs.")]
		[DisplayName("AOE Melee Targets")]
        public int AOEMeleeLimit { get; set; }

		[Setting]
		[Category("AOE")]
        [DefaultValue(3)]
		[Description("If more than this number of targets are in range of ninjutsu, use AOEs.")]
		[DisplayName("AOE Ninjutsu Targets")]
        public int AOENinjutsuLimit { get; set; }
		
		[Setting]
		[Category("AOE")]
        [DefaultValue(false)]
		[Description("If true, routine will automatically use AOE abilities if they will hit at least the number of specified targets.")]
		[DisplayName("Automatic AOE")]
        public bool AutoAOE { get; set; }
		
		[Setting]
		[Category("AOE")]
        [DefaultValue(false)]
		[Description("If true, routine will use AOE regardless of the number of targets.")]
		[DisplayName("AOE Override")]
        public bool AOEOverride { get; set; }
		
		[Setting]
		[Category("AOE")]
        [DefaultValue(200)]
		[Description("Routine will stop using AOE when TP is below this amount")]
		[DisplayName("AOE TP Limit")]
        public int AOETPLimit { get; set; }
		
		[Setting]
		[Category("AOE")]
        [DefaultValue(true)]
		[Description("If enabled, Kupper will keep Huton up during AOE.")]
		[DisplayName("Huton + AOE")]
        public bool AOEHuton { get; set; }
		
		//Combat
		[Setting]
		[Category("Combat")]
        [DefaultValue(2000)]
		[Description("DOTs will only be applied if the target's HP is above this value")]
		[DisplayName("* DOT HP Limit *")]
        public int DOTLimit { get; set; }
		
		[Setting]
        [Category("Combat")]
        [DefaultValue(false)]
        [DisplayName("Sneak Attack")]
        public bool UseSneakAttack { get; set; }
		
		[Setting]
        [Category("Combat")]
        [DefaultValue(true)]
        [DisplayName("Trick	Attack")]
        public bool UseTrickAttack { get; set; }
		
		[Setting]
        [Category("Combat")]
        [DefaultValue(true)]
        [DisplayName("Dancing Edge")]
        public bool UseDancingEdge { get; set; }

		//Buffs
        [Setting]
        [Category("Buffs")]
        [DefaultValue(true)]
        [DisplayName("* Use Buffs *")]
        public bool UseBuffs { get; set; }
		
		[Setting]
        [Category("Buffs")]
        [DefaultValue(3000)]
        [Description("Buffs will only be used if the target's HP is above this value")]
		[DisplayName("* Buff HP Limit *")]
        public int BuffHPLimit { get; set; }

        [Setting]
        [DefaultValue(true)]
        [Category("Buffs")]
        [DisplayName("Internal Release")]
        public bool UseInternalRelease { get; set; }

		[Setting]
        [DefaultValue(true)]
        [Category("Buffs")]
        [DisplayName("Blood for Blood")]
        public bool UseBloodForBlood { get; set; }
		
		[Setting]
        [DefaultValue(true)]
        [Category("Buffs")]
        [DisplayName("Kiss of the Wasp")]
        public bool UseWasp { get; set; }
		
		[Setting]
        [DefaultValue(true)]
        [Category("Buffs")]
        [DisplayName("Kiss of the Viper")]
        public bool UseViper { get; set; }
		
		//Defensives
		
		[Setting]
        [DefaultValue(54)]
        [Category("Defensives")]
        [DisplayName("Invigorate TP %")]
        public int UseInvigorateTP { get; set; }
		
		[Setting]
        [DefaultValue(40)]
        [Category("Defensives")]
        [DisplayName("Second Wind HP %")]
        public int UseSecondWindHP { get; set; }
		
		[Setting]
        [DefaultValue(40)]
        [Category("Defensives")]
        [DisplayName("Featherfoot HP %")]
        public int UseFeatherfootHP { get; set; }
		
		[Setting]
        [DefaultValue(500)]
        [Category("Defensives")]
        [DisplayName("Goad TP")]
        public int UseGoadTP { get; set; }
		
		[Setting]
        [DefaultValue(true)]
        [Category("Defensives")]
        [DisplayName("Goad")]
        public bool UseGoad { get; set; }
		
		
		//Ninjutsu
		
		[Setting]
        [DefaultValue(true)]
        [Category("Ninjutsu")]
        [DisplayName("Kassatsu")]
        public bool UseKassatsu { get; set; }
		
		[Setting]
        [DefaultValue(true)]
        [Category("Ninjutsu")]
        [DisplayName("Huton")]
        public bool UseHuton { get; set; }
		
		[Setting]
        [DefaultValue(true)]
        [Category("Ninjutsu")]
        [DisplayName("Suiton")]
        public bool UseSuiton { get; set; }
		
		[Setting]
        [DefaultValue(true)]
        [Category("Ninjutsu")]
        [DisplayName("Raiton")]
        public bool UseRaiton { get; set; }
		
		[Setting]
        [DefaultValue(true)]
        [Category("Ninjutsu")]
        [DisplayName("Fuma Shuriken")]
        public bool UseFumaShuriken { get; set; }
		
		[Setting]
		[DefaultValue(true)]
		[Category("Ninjutsu")]
		[DisplayName("Doton")]
		public bool UseDoton { get; set; }
		
		[Setting]
		[DefaultValue(false)]
		[Category("Ninjutsu")]
		[DisplayName("Allow Kassatsu+Suiton")]
		public bool KassatsuSuiton { get; set; }
		
		[Setting]
		[DefaultValue(false)]
		[Category("Ninjutsu")]
		[DisplayName("Allow Kassatsu+Doton")]
		public bool KassatsuDoton { get; set; }		
		
		[Setting]
		[DefaultValue(false)]
		[Category("Ninjutsu")]
		[DisplayName("Allow Kassatsu+Huton")]
		public bool KassatsuHuton { get; set; }
		
		[Setting]
		[DefaultValue(0)]
		[Category("Ninjutsu")]
		[DisplayName("Ninjutsu HP Limit")]
		public int NinjutsuHPLimit { get; set; }
		
		//Clipping and timers
		
		[Setting]
		[Category("Clipping & Timers")]
        [DefaultValue(2000)]
		[Description("Kupper will refresh Mutilation if less than this many ms remain.")]
		[DisplayName("Mutilate Clipping")]
        public int MutilateClip { get; set; }
		
		[Setting]
		[Category("Clipping & Timers")]
        [DefaultValue(3000)]
		[Description("Kupper will refresh Shadow Fang if less than this many ms remain.")]
		[DisplayName("Shadow Fang Clipping")]
        public int ShadowFangClip { get; set; }
		
		[Setting]
		[Category("Clipping & Timers")]
        [DefaultValue(3000)]
		[Description("Kupper will refresh Dancing Edge if less than this many ms remain.")]
		[DisplayName("Dancing Edge Clipping")]
        public int DancingEdgeClip { get; set; }
		
		[Setting]
		[Category("Clipping & Timers")]
        [DefaultValue(12500)]
		[Description("Kupper will use Kassatsu if more than this many ms remain until ninjutsu is ready.")]
		[DisplayName("Kassatsu Timer")]
        public int KassatsuTimer { get; set; }
		
		[Setting]
		[Category("Clipping & Timers")]
        [DefaultValue(15000)]
		[Description("Kupper will use Huton if less than this many ms remain.")]
		[DisplayName("Huton Clipping")]
        public int HutonClip { get; set; }
		
		//Debug
		
		[Setting]
        [DefaultValue(false)]
        [Category("- Debug -")]
		[Description("This generates HUGE logs. Only use this if you are having a problem with the routine and you want to submit a log.")]
        [DisplayName("Debug")]
        public bool UseDebug { get; set; }
		
				private List<String> _interrupt;
				
		[Description("Spells which should be interrupted.")]
        [Editor(@"System.Windows.Forms.Design.StringCollectionEditor," + 
			"System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a",
			typeof(System.Drawing.Design.UITypeEditor))]
		[TypeConverter(typeof(CsvConverter))]
        [Category("Interrupts")]
        [DisplayName("Spells to Interrupt")]
        public List<String> Interrupt
        {
            get
            {
                if (_interrupt == null)
                    _interrupt = new List<String>();
                return _interrupt;
            }
        }

						private List<String> _DontDOT;
				
		[Description("Enemies which should not have DOTs applied.")]
        [Editor(@"System.Windows.Forms.Design.StringCollectionEditor," + 
			"System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a",
			typeof(System.Drawing.Design.UITypeEditor))]
		[TypeConverter(typeof(CsvConverter))]
        [Category("Combat")]
        [DisplayName("Don't DOT Targets")]
        public List<String> DontDOT
        {
            get
            {
                if (_DontDOT == null)
                    _DontDOT = new List<String>();
                return _DontDOT;
            }
        }

		
		private List<String> _DontAOE;
				
		[Description("Enemies to not use AOE against")]
        [Editor(@"System.Windows.Forms.Design.StringCollectionEditor," + 
			"System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a",
			typeof(System.Drawing.Design.UITypeEditor))]
		[TypeConverter(typeof(CsvConverter))]
        [Category("AOE")]
        [DisplayName("Don't AOE Targets")]
        public List<String> DontAOE
        {
            get
            {
                if (_DontAOE == null)
                    _DontAOE = new List<String>();
                return _DontAOE;
            }
        }

		private List<String> _FumaTargets;
				
		[Description("Targets to use Fuma Shuriken instead of Raiton (For targets that resist magic)")]
        [Editor(@"System.Windows.Forms.Design.StringCollectionEditor," + 
			"System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a",
			typeof(System.Drawing.Design.UITypeEditor))]
		[TypeConverter(typeof(CsvConverter))]
        [Category("Ninjutsu")]
        [DisplayName("Fuma Shuriken Targets")]
        public List<String> FumaTargets
        {
            get
            {
                if (_FumaTargets == null)
                    _FumaTargets = new List<String>();
                return _FumaTargets;
            }
        }
		
		[Setting]
        [DefaultValue(true)]
        [Category("Combat")]
        [DisplayName("Assassinate")]
        public bool UseAssassinate { get; set; }
		
		[Setting]
        [DefaultValue(false)]
		[Description("This may interrupt ninjutsu if a stun/silence is required while mudra is active.")]
        [Category("Interrupts")]
        [DisplayName("Stun/Silence")]
        public bool UseInterrupt { get; set; }

		[Setting]
        [DefaultValue(true)]
		[Description("Use this to disable jugulate if you need to do interrupts but don't want the bot doing them for you.")]
        [Category("Interrupts")]
        [DisplayName("Jugulate")]
        public bool UseJugulate { get; set; }
		
		[Setting]
        [Category("Potions")]
        [DefaultValue(false)]
        [DisplayName("Dexterity Potions")]
        public bool UseBuffPotions { get; set; }
		
		[Setting]
        [Category("Potions")]
        [DefaultValue(false)]
        [DisplayName("Poison Potions")]
        public bool UsePoisonPotions { get; set; }
		
		
    }


}